<!--修改密码-->
<html>
<head>
    <meta charset="utf-8">
    <title>${readercard.name}的主页</title>
    <!--<link rel="stylesheet" href="css/bootstrap.min.css">-->
    <!--<script src="js/jquery-3.3.1.js"></script>-->
    <!--<script src="js/bootstrap.min.js" ></script>-->
    <!--<script src="js/getParameter.js"></script>-->
    <style>
        body{
            background-color: rgb(240,242,245);
        }
        #reader *{
            color: #333;
        }
    </style>
</head>
<body>

<div id="msg" style="position: relative;top: 15%">
    <div class="alert alert-dismissable">
        &nbsp;
    </div>
</div>
<div class="col-xs-6 col-md-offset-3" style="position: relative;top: 25%">
    <div class="panel panel-primary " >
        <div class="panel-heading">
            <h3 class="panel-title">密码修改</h3>
        </div>
        <div class="panel-body">
            <form class="form-inline"  id="repasswd" >
                <div class="input-group">
                    <input type="password" id="oldPasswd" name="oldPasswd" placeholder="输入旧密码" class="form-control">
                    <input type="password" id="newPasswd" name="newPasswd" placeholder="输入新密码" class="form-control">
                    <input type="password" id="reNewPasswd" name="reNewPasswd" placeholder="再次输入新密码" class="form-control">
                    <em id="tishi" style="color: red"></em>
                    <br/>
                    <span>
                        <input type="submit" value="点击修改" class="btn btn-default" name="submit">
                    </span>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    function mySubmit(flag){
        return flag;
    }

    $(document).keyup(function () {
        if($("#newPasswd").val()!=$("#reNewPasswd").val()&&$("#newPasswd").val()!=""&&$("#reNewPasswd").val()!=""&&$("#newPasswd").val().length==$("#reNewPasswd").val().length){
            $("#tishi").text("提示:两次输入的新密码不同，请检查!");
        }
        else {
            $("#tishi").text("");
        }
    })

    $("#repasswd").submit(function () {
        if($("#oldPasswd").val()==''||$("#newPasswd").val()==''||$("#reNewPasswd").val()==''){
            $("#tishi").text("提示:请填写完整!");
            return mySubmit(false);
        }
        else if($("#newPasswd").val()!=$("#reNewPasswd").val()){
            $("#tishi").text("提示:两次输入的新密码不同，请检查!");
            return mySubmit(false);
        }
        $.post("user/modifyPass",{
            id: reader_id,
            oldPass: $("#oldPasswd").val(),
            newPass: $("#newPasswd").val()
        }, function(data){
            switch (data.code){
                case 0:
                    $(".alert").removeClass("alert-success");
                    $(".alert").addClass("alert-danger");
                    $(".alert").html("<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>"+data.message);
                    break;
                case 1:
                    // location.href="index.html";
                    $("#middle").load("index.html");
                    break;
            }
        },"json");
        return false;
    })
</script>


</body>
</html>
